{extend  name="manage@public/layout" /}
{block name="content"}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5 style="margin:-5px 5px 0px !important;">
                            <button onClick="modaldemo(0)" style="padding:4px;margin-bottom:0 !important" type="button" class="btn btn-primary btn-xs">添加代理</button>
                        </h5>
                        <div class="ibox-tools">
                            <a class="collapse-link" onclick="location.replace(location.href);">
                                <i class="fa fa-refresh"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <!--- 搜索--->
                            <form action="" method="post">
                                <div class="col-sm-2 col-sm-on">
                                    <select class="input-sm form-control input-s-sm inline">
                                        <option value="0">请选择状态</option>
                                        <option value="1">正常</option>
                                        <option value="2">禁用</option>
                                    </select>
                                </div>
                                <div class="col-sm-2 col-sm-on">
                                    <select class="input-sm form-control input-s-sm inline">
                                        <option value="0">入金状态</option>
                                        <option value="1">正常</option>
                                        <option value="2">禁用</option>
                                    </select>
                                </div>
                                <div class="col-sm-2 col-sm-on">
                                    <select class="input-sm form-control input-s-sm inline">
                                        <option value="0">出款状态</option>
                                        <option value="1">正常</option>
                                        <option value="2">禁用</option>
                                    </select>
                                </div>
                                <div class="col-sm-2 col-sm-on">
                                    <input type="text" name="keyword" placeholder="代理名称" class="input-sm form-control">
                                </div>
                                <div class="col-sm-1 col-sm-on col-sm-botton">
                                    <div class="input-group">
                                        <button type="button" class="btn btn-sm btn-primary"><i class="fa fa-search"></i></button>
                                    </div>
                                </div>
                            </form>
                            <!--- end --->
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>账号</th>
                                        <th>代理名称</th>
                                        <th>代理费率</th>
                                        <th>余额</th>
                                        <th>冻结金额</th>
                                        <th>状态</th>
                                        <th>入金</th>
                                        <th>下发</th>
                                        <th>注册时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {volist name="list" id="vo"}
                                    <tr>
                                        <td>{$vo.id}</td>
                                        <td>{$vo.mch}</td>
                                        <td>{$vo.mch_name}</td>
                                        <td>{$vo.agent_rate|abs}</td>
                                        <td>{$vo.balance|abs}</td>
                                        <td>{$vo.freeze|abs}</td>
                                        <td>
                                            <input data-type="zt" data-url="{:url('/manage/statusMch')}" {eq  name="vo.status" value="1"}checked{/eq} data-id="{$vo.id}" type="checkbox" class="js-switch"  />
                                        </td>
                                        <td>
                                            <input data-type="rj" data-url="{:url('/manage/statusMch')}" {eq  name="vo.rukuan" value="1"}checked{/eq} data-id="{$vo.id}" type="checkbox" class="js-switch"  />
                                        </td>
                                        <td>
                                            <input data-type="ck" data-url="{:url('/manage/statusMch')}" {eq  name="vo.chukuan" value="1"}checked{/eq} data-id="{$vo.id}" type="checkbox" class="js-switch"  />
                                        </td>
                                        <td>{$vo.create_time}</td>
                                        <td>
                                            <a style="color: #1ab394;border: 1px solid #1ab394;" href="{:url('/manage/mchEdit',['id'=>$vo.id])}" title="编辑" type="button" class="btn btn-sm btn-white"><i class="fa fa-edit">&nbsp;编辑</i></a>
                                            <button style="color: #f96c08;border: 1px solid #f96c08;"  onClick="modalamount({$vo.id},{$vo.balance},{$vo.freeze})" title="加/减、冻结/解冻" type="button" data-id="{$vo.id}" class="btn btn-sm bt-agent-balance btn-white"><i class="fa fa-dollar">&nbsp;修改金额</i></button>
                                            <a href="{:url('/manage/agentConf',['id'=>$vo.id])}" style="color: #337ab7;border: 1px solid #337ab7;"  title="配置渠道" type="button" data-id="{$vo.id}" class="btn btn-sm bt-agent-balance btn-white"><i class="fa fa-wifi">&nbsp;配置渠道</i></a>
                                            <button style="color:red;border:1px solid red;" title="删除代理商" type="button" data-id="{$vo.id}" class="btn btn-sm bt-mch-del btn-white"><i class="fa fa-trash-o"></i>&nbsp;删除</button>
                                        </td>
                                    </tr>
                                    {/volist}
                                </tbody>
                            </table>
                            <div style="float:right;" class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
                                {$page|raw}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div> 
    <!-- 弹框 --->
    <div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
        <div class="modal-dialog">
            <div class="modal-content radius">
                <div class="modal-header">
                    <h3 class="modal-title">添加代理</h3>
                    <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
                </div>
                <input type="hidden" name="role_id" value="0" />
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">代理名称</label>
                        <div class="col-sm-7">
                            <input type="text" placeholder="请输入代理名称" name="user_name" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">代理费率</label>
                        <div class="col-sm-7">
                            <input type="text" onkeyup="this.value= this.value.match(/\d+(\.\d{0,3})?/) ? this.value.match(/\d+(\.\d{0,3})?/)[0] : ''" placeholder="例如：0.035" name="agent_rate" class="form-control">
                        </div>
                    </div>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">登录密码</label>
                        <div class="col-sm-7">
                            <input type="password" placeholder="请输入登录密码" name="password" class="form-control">
                        </div>
                    </div>
                </div>
                <!-- {if count($agent)>0}
                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">上级代理</label>
                        <div class="col-sm-7">
                            <select id="agent" class="form-control m-b" name="agent">
                                <option value="0">请选择代理</option>
                                {volist name="agent" id="vo"}
                                <option value="{$vo.auth_admin}">{$vo.mch}[{$vo.mch_name}]</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>
                {/if} -->
                <div class="modal-footer">
                    <button class="btn btn-primary btn-agent">确定</button>
                    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <!--  end --->
   <!-- 弹框 --->
   <div id="modal-amount" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content radius">
            <div class="modal-header">
                <h3 class="modal-title">变更金额</h3>
                <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
            </div>
            <input type="hidden" id="mch_id" name="mch_id" value="0" />
            
            <div class="col-sm-12" style="margin-top:15px;">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li style="width:50%;text-align:center;" class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">加/减余额</a>
                        </li>
                        <li style="width:50%;text-align:center;" class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">冻结/解冻</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <div style="padding-bottom: 0px;" class="panel-body">
                                <div class="modal-body" style="padding: 5px 30px !important;">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">可用/冻结</label>
                                        <div class="col-sm-7">
                                            <input type="text" id="id-balance" value="" disabled class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div style="margin: 5px;" class="hr-line-dashed"></div>
                                <div class="modal-body" style="padding: 5px 30px !important;">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">操作</label>
                                        <div class="col-sm-7">
                                            <div class="radio i-checks">
                                                <label style="padding-left: 0 !important;"><input type="radio" name="type" checked value="1"> <i></i> 增加金额</label>
                                                <label><input type="radio"  name="type" value="2"> <i></i> 减少金额</label>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div style="margin: 5px;" class="hr-line-dashed"></div>
                                <div class="modal-body" style="padding: 5px 30px !important;">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">变动金额</label>
                                        <div class="col-sm-7">
                                            <input type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,3})?).*$/g, '$1')" placeholder="请输入变动金额" name="balance" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div style="margin: 5px;" class="hr-line-dashed"></div>
                                <div class="modal-body">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">备注</label>
                                        <div class="col-sm-7">
                                            <textarea id="remark" class="input-sm form-control" rows="4" cols="30" style="border: 1px solid #e5e6e7;" placeholder="请输入内容" name="remark"></textarea>
                                        </div>
                                    </div>
                                </div>
                                
                                <div style="text-align:center;" class="col-sm-12">
                                    <button class="btn btn-primary balance-edit" type="submit">修改</button>  
                                </div>
                            </div>
                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div style="padding-bottom: 0px;" class="panel-body">
                                <div class="modal-body" style="padding: 5px 30px !important;">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">冻结/可用金额</label>
                                        <div class="col-sm-7">
                                            <input type="text" id="do-id-balance" value="" disabled class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div style="margin: 5px;" class="hr-line-dashed"></div>
                                <div class="modal-body" style="padding: 5px 30px !important;">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">操作</label>
                                        <div class="col-sm-7">
                                            <div class="radio i-checks">
                                                <label style="padding-left: 0 !important;"><input name="do-type" type="radio" checked value="1"> <i></i> 冻结金额</label>
                                                <label><input type="radio"  name="do-type" value="2"> <i></i> 解冻金额</label>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div style="margin: 5px;" class="hr-line-dashed"></div>
                                <div class="modal-body" style="padding: 5px 30px !important;">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">变动金额</label>
                                        <div class="col-sm-7">
                                            <input type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,3})?).*$/g, '$1')" placeholder="请输入变动金额" name="do-balance" class="form-control">
                                        </div>
                                    </div>
                                </div>
                                <div style="margin: 5px;" class="hr-line-dashed"></div>
                                <div class="modal-body">
                                    <div style="height:34px;" class="">
                                        <label class="col-sm-3 control-label">备注</label>
                                        <div class="col-sm-7">
                                            <textarea id="do-remark" class="input-sm form-control" rows="4" cols="30" style="border: 1px solid #e5e6e7;" placeholder="请输入内容" name="do-remark"></textarea>
                                        </div>
                                    </div>
                                </div>
                                <div style="text-align:center;" class="col-sm-12">
                                    <button class="btn btn-primary do-balance-edit" type="submit">修改</button>  
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer"></div>
        </div>
    </div>
</div>
<!--  end --->
{/block}
{block name="script"}
<script src="/static/js/admin/mch.js"></script>
<script>
    function modaldemo() {
        $("#modal-demo").modal("show");
    }
    function modaldemoAgent(id,balance,freeze) {
        $("#agent_id").val(id);
        $("#id-balance").val('可用：'+balance+'元   冻结：'+freeze+'元');
        $("#do-id-balance").val('冻结：'+freeze+'元   可用：'+balance+'元');
        $("#modal-demo-agent").modal("show");
    }
</script>
{/block}

